<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - src/caffe/layers/hdf5_output_layer.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">src/caffe/layers</a> - hdf5_output_layer.cpp<span style="font-size: 80%;"> (source / <a href="hdf5_output_layer.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntry">37</td>
            <td class="headerCovTableEntryLo">5.4 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:25:26</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntry">20</td>
            <td class="headerCovTableEntryLo">10.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #ifdef USE_HDF5</a>
<span class="lineNum">       2 </span>            : #include &lt;vector&gt;
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : #include &quot;hdf5.h&quot;
<span class="lineNum">       5 </span>            : #include &quot;hdf5_hl.h&quot;
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #include &quot;caffe/layers/hdf5_output_layer.hpp&quot;
<span class="lineNum">       8 </span>            : #include &quot;caffe/util/hdf5.hpp&quot;
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : namespace caffe {
<a name="11"><span class="lineNum">      11 </span>            : </a>
<span class="lineNum">      12 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      13 </span><span class="lineNoCov">          0 : void HDF5OutputLayer&lt;Dtype&gt;::LayerSetUp(const vector&lt;Blob&lt;Dtype&gt;*&gt;&amp; bottom,</span>
<span class="lineNum">      14 </span>            :     const vector&lt;Blob&lt;Dtype&gt;*&gt;&amp; top) {
<span class="lineNum">      15 </span><span class="lineNoCov">          0 :   file_name_ = this-&gt;layer_param_.hdf5_output_param().file_name();</span>
<span class="lineNum">      16 </span><span class="lineNoCov">          0 :   file_id_ = H5Fcreate(file_name_.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT,</span>
<span class="lineNum">      17 </span>            :                        H5P_DEFAULT);
<span class="lineNum">      18 </span><span class="lineNoCov">          0 :   CHECK_GE(file_id_, 0) &lt;&lt; &quot;Failed to open HDF5 file&quot; &lt;&lt; file_name_;</span>
<span class="lineNum">      19 </span><span class="lineNoCov">          0 :   file_opened_ = true;</span>
<span class="lineNum">      20 </span><span class="lineNoCov">          0 : }</span>
<a name="21"><span class="lineNum">      21 </span>            : </a>
<span class="lineNum">      22 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      23 </span><span class="lineNoCov">          0 : HDF5OutputLayer&lt;Dtype&gt;::~HDF5OutputLayer&lt;Dtype&gt;() {</span>
<span class="lineNum">      24 </span><span class="lineNoCov">          0 :   if (file_opened_) {</span>
<span class="lineNum">      25 </span><span class="lineNoCov">          0 :     herr_t status = H5Fclose(file_id_);</span>
<span class="lineNum">      26 </span><span class="lineNoCov">          0 :     CHECK_GE(status, 0) &lt;&lt; &quot;Failed to close HDF5 file &quot; &lt;&lt; file_name_;</span>
<span class="lineNum">      27 </span>            :   }
<span class="lineNum">      28 </span><span class="lineNoCov">          0 : }</span>
<a name="29"><span class="lineNum">      29 </span>            : </a>
<span class="lineNum">      30 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      31 </span><span class="lineNoCov">          0 : void HDF5OutputLayer&lt;Dtype&gt;::SaveBlobs() {</span>
<span class="lineNum">      32 </span>            :   // TODO: no limit on the number of blobs
<span class="lineNum">      33 </span><span class="lineNoCov">          0 :   LOG(INFO) &lt;&lt; &quot;Saving HDF5 file &quot; &lt;&lt; file_name_;</span>
<span class="lineNum">      34 </span><span class="lineNoCov">          0 :   CHECK_EQ(data_blob_.num(), label_blob_.num()) &lt;&lt;</span>
<span class="lineNum">      35 </span>            :       &quot;data blob and label blob must have the same batch size&quot;;
<span class="lineNum">      36 </span><span class="lineNoCov">          0 :   hdf5_save_nd_dataset(file_id_, HDF5_DATA_DATASET_NAME, data_blob_);</span>
<span class="lineNum">      37 </span><span class="lineNoCov">          0 :   hdf5_save_nd_dataset(file_id_, HDF5_DATA_LABEL_NAME, label_blob_);</span>
<span class="lineNum">      38 </span><span class="lineNoCov">          0 :   LOG(INFO) &lt;&lt; &quot;Successfully saved &quot; &lt;&lt; data_blob_.num() &lt;&lt; &quot; rows&quot;;</span>
<span class="lineNum">      39 </span><span class="lineNoCov">          0 : }</span>
<a name="40"><span class="lineNum">      40 </span>            : </a>
<span class="lineNum">      41 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      42 </span><span class="lineNoCov">          0 : void HDF5OutputLayer&lt;Dtype&gt;::Forward_cpu(const vector&lt;Blob&lt;Dtype&gt;*&gt;&amp; bottom,</span>
<span class="lineNum">      43 </span>            :       const vector&lt;Blob&lt;Dtype&gt;*&gt;&amp; top) {
<span class="lineNum">      44 </span><span class="lineNoCov">          0 :   CHECK_GE(bottom.size(), 2);</span>
<span class="lineNum">      45 </span><span class="lineNoCov">          0 :   CHECK_EQ(bottom[0]-&gt;num(), bottom[1]-&gt;num());</span>
<span class="lineNum">      46 </span><span class="lineNoCov">          0 :   data_blob_.Reshape(bottom[0]-&gt;num(), bottom[0]-&gt;channels(),</span>
<span class="lineNum">      47 </span>            :                      bottom[0]-&gt;height(), bottom[0]-&gt;width());
<span class="lineNum">      48 </span><span class="lineNoCov">          0 :   label_blob_.Reshape(bottom[1]-&gt;num(), bottom[1]-&gt;channels(),</span>
<span class="lineNum">      49 </span>            :                      bottom[1]-&gt;height(), bottom[1]-&gt;width());
<span class="lineNum">      50 </span><span class="lineNoCov">          0 :   const int data_datum_dim = bottom[0]-&gt;count() / bottom[0]-&gt;num();</span>
<span class="lineNum">      51 </span><span class="lineNoCov">          0 :   const int label_datum_dim = bottom[1]-&gt;count() / bottom[1]-&gt;num();</span>
<span class="lineNum">      52 </span>            : 
<span class="lineNum">      53 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; bottom[0]-&gt;num(); ++i) {</span>
<span class="lineNum">      54 </span><span class="lineNoCov">          0 :     caffe_copy(data_datum_dim, &amp;bottom[0]-&gt;cpu_data()[i * data_datum_dim],</span>
<span class="lineNum">      55 </span><span class="lineNoCov">          0 :         &amp;data_blob_.mutable_cpu_data()[i * data_datum_dim]);</span>
<span class="lineNum">      56 </span><span class="lineNoCov">          0 :     caffe_copy(label_datum_dim, &amp;bottom[1]-&gt;cpu_data()[i * label_datum_dim],</span>
<span class="lineNum">      57 </span><span class="lineNoCov">          0 :         &amp;label_blob_.mutable_cpu_data()[i * label_datum_dim]);</span>
<span class="lineNum">      58 </span>            :   }
<span class="lineNum">      59 </span><span class="lineNoCov">          0 :   SaveBlobs();</span>
<span class="lineNum">      60 </span><span class="lineNoCov">          0 : }</span>
<a name="61"><span class="lineNum">      61 </span>            : </a>
<span class="lineNum">      62 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      63 </span><span class="lineNoCov">          0 : void HDF5OutputLayer&lt;Dtype&gt;::Backward_cpu(const vector&lt;Blob&lt;Dtype&gt;*&gt;&amp; top,</span>
<span class="lineNum">      64 </span>            :       const vector&lt;bool&gt;&amp; propagate_down, const vector&lt;Blob&lt;Dtype&gt;*&gt;&amp; bottom) {
<span class="lineNum">      65 </span><span class="lineNoCov">          0 :   return;</span>
<span class="lineNum">      66 </span>            : }
<a name="67"><span class="lineNum">      67 </span>            : </a>
<span class="lineNum">      68 </span>            : #ifdef CPU_ONLY
<span class="lineNum">      69 </span><span class="lineNoCov">          0 : STUB_GPU(HDF5OutputLayer);</span>
<span class="lineNum">      70 </span>            : #endif
<a name="71"><span class="lineNum">      71 </span>            : </a>
<span class="lineNum">      72 </span>            : INSTANTIATE_CLASS(HDF5OutputLayer);
<a name="73"><span class="lineNum">      73 </span><span class="lineCov">          3 : REGISTER_LAYER_CLASS(HDF5Output);</span></a>
<span class="lineNum">      74 </span>            : 
<span class="lineNum">      75 </span><span class="lineCov">          3 : }  // namespace caffe</span>
<span class="lineNum">      76 </span>            : #endif  // USE_HDF5
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
